package com.adopapa.ethexplorer.conf;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.web.reactive.config.CorsRegistry;
import org.springframework.web.reactive.config.WebFluxConfigurer;


@Configuration
public class CorsConfig implements WebFluxConfigurer {
	
	protected Logger logger = LoggerFactory.getLogger(this.getClass());

	
    /**
     * 全局跨域配置，根据各自需求定义
     * @param registry
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
    	logger.info("registry cors config ...... ");
        registry.addMapping("/**")//
                .allowCredentials(true)//
                .allowedOriginPatterns("*")//
                .allowedHeaders("*")//
                .allowedMethods("*")//
                .exposedHeaders(HttpHeaders.SET_COOKIE);
    }

}